#include <bits/stdc++.h>

using namespace std;
class Singleton{
   public:
   int data=0;
   static Singleton& getInstance(){
       static Singleton instance;
       return instance; //局部静态变量
   }
   void fun()
   {
       data=data+1;
   }
   void display()
   {
       cout<<data<<endl;
   }
    private:
    Singleton()=default;
    ~Singleton()=default;
   Singleton(const Singleton& other)=delete;//禁止使用拷贝构造函数
   Singleton& operator=(const Singleton&)=delete;//禁止使用拷贝赋值运算符
};

class Observer
{
public:
    virtual void update() = 0;
};

class Observable
{
public:
    virtual void addObserver(Observer&) = 0;
    virtual void deleteObserver(Observer&) = 0;
    virtual void notifyObservers() = 0;
};


int main()
{
   Singleton& c= Singleton::getInstance();
  Singleton& b= Singleton::getInstance();

c.display();
b.fun();
b.fun();
c.display();

   return 0;
}
